<?php
include_once 'application/controllers/AbstractController.php';
require_once 'application/models/BatterieType.php';

class BatterieTypeController extends AbstractController 
{
	function indexAction()
    {
		parent::indexAction();
    	HttpUtil::do405();
    }
    
    
    function getAction()
    {
		parent::getAction();
    	//TODO: check rights pour chaque fonction (Zend_Acl ?)
		
	    $batterieType = new BatterieType();
	    $batterieTypeRows = $batterieType->fetchAll();
	    
    	//check asnwer : 404 if not found
	    if (isset($batterieTypeRows[0])) {
		    $result = array();
			
			foreach ($batterieTypeRows as $bt) {
				$result[$bt->id] = array(
					"id" => $bt->id,
					"nom" => $bt->nom,
					"description" => $bt->description,
					"modifiable_par_defaut" => $bt->modifiable_par_defaut
				);
			}
			
			// render
			$this->view->data = json_encode($result, JSON_FORCE_OBJECT);
	    }else{
			HttpUtil::do404();
	    }
    }
    
    function postAction()
    {
		parent::postAction();
    	HttpUtil::do405();
    }

    
    
    
    function putAction()
    {
		parent::putAction();
    	HttpUtil::do405();
    }
    
    
    
    function deleteAction()
    {
		parent::deleteAction();
    	HttpUtil::do405();
    }
}
